package com.cysyz.mylib.hibernatedao;


import com.cysyz.mylib.dao.engine.Query;

import java.util.Collection;
import java.util.List;

class QueryHibernate implements Query {
    private org.hibernate.Query query;
		
		public QueryHibernate(org.hibernate.Query query) {
			super();
			this.query = query;
		}
		
		public String getQueryString() {
			return this.query.getQueryString();
		}
		
		public void setCacheAble(boolean isCacheAble) {
			query.setCacheable(true);
		}
		
		@SuppressWarnings("rawtypes")
		public List getResultList() {
			return query.list();
		}

		public Query setFirstResult(int firstResult) {
			query.setFirstResult(firstResult);
			return this;
		}

		public Query setMaxResults(int maxresult) {
			query.setMaxResults(maxresult);
			return this;
		}

		public void setParameter(Integer placeHolder, Object value) {
			query.setParameter(placeHolder, value);
		}

		public Object getSingleResult() {
			return query.uniqueResult();
		}
		
		public int execute() {
			return query.executeUpdate();
		}

		@Override
		public void setParameterList(String placeHolder, Collection<?> param) {
			query.setParameterList(placeHolder, param);
		}

		@Override
		public void setParameterList(String placeHolder, Object[] param) {
			query.setParameterList(placeHolder, param);
		}

		@Override
		public void setParameter(String placeHolder, Object value) {
			query.setParameter(placeHolder, value);
		}
	}